package edu.uitls;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class AgeUtils {
    private AgeUtils() {
    }

    public static String getAge(String birthday) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date date = sdf.parse(birthday);
            Long dateTime = date.getTime();
            Date nowDate = new Date();
            Long nowTime = nowDate.getTime();
            Long age = (nowTime-dateTime)/365/24/3600/1000;
            return age + "";

        } catch (ParseException e) {
            //e.printStackTrace();
        }
        return "-1";
    }
}
